// NozzleFactory.cpp: implementation of the NozzleFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "NozzleFactory.h"
#include "NozzleHeader.h"
#include "NozzleIdentity.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

NozzleFactory::NozzleFactory()
{

}

NozzleFactory::~NozzleFactory()
{

}

Nozzle* NozzleFactory::CreateStraightNozzle()
{
	Nozzle* pNozzle = new StraightNozzle;
	NozzleGeometry* pNozzleGeo = new StraightNozzleGeometry(pNozzle);

	ASSERT((pNozzle!=NULL)&&(pNozzleGeo!=NULL));
	pNozzle->Attach(pNozzleGeo);

	return pNozzle;
}

Nozzle* NozzleFactory::CreateCurvousNozzle()
{
	Nozzle* pNozzle = new CurvingNozzle;

	NozzleGeometry* pNozzleGeo = new CurvingNozzleGeometry(pNozzle);

	ASSERT((pNozzle!=NULL)&&(pNozzleGeo!=NULL));
	pNozzle->Attach(pNozzleGeo);

	return pNozzle;

}
Nozzle* NozzleFactory::CreateStraightNozzle(const NozzleCreateDoc& Identity)
{
	Nozzle* pNozzle = new StraightNozzle;
	ASSERT( pNozzle!=NULL );
	SetIdentity(pNozzle ,Identity);

	NozzleGeometry* pNozzleGeo = 
		new StraightNozzleGeometry(pNozzle);
	ASSERT( pNozzleGeo != NULL );
	pNozzle->Attach( pNozzleGeo );

	return pNozzle;
}

Nozzle* NozzleFactory::CreateCurvousNozzle(const NozzleCreateDoc& Identity)
{
	Nozzle* pNozzle = new CurvingNozzle;
	ASSERT( pNozzle != NULL);
	SetIdentity(pNozzle ,Identity);

	NozzleGeometry* pNozzleGeo =
		new CurvingNozzleGeometry(pNozzle);
	ASSERT( pNozzleGeo!=NULL );
	pNozzle->Attach(pNozzleGeo);

	return pNozzle;

}

void NozzleFactory::SetIdentity(Nozzle *pNozzle, const NozzleCreateDoc &Identity)
{
	pNozzle->SetEndType(Identity.GetFaceType());
	pNozzle->SetRank(Identity.GetPipeRank());
	pNozzle->SetHeatPreserveType(Identity.GetHeatPreservationType());
	pNozzle->SetNozzleID(Identity.GetNozzleID());
	pNozzle->SetNozzleName(Identity.GetNozzleName());
	pNozzle->SetPipeID(Identity.GetPipeID());
}
